package string;

public class ValueOfDemo {
    public static void main(String[] args) {
        int a=123;
        String s1=String.valueOf(a);//将int型变量a转换为String类型并赋值
        System.out.println(s1);//123字符串类型

        double b=123.456;
        String s2=String.valueOf(b);//将double型变量b转换为String类型并赋值
        System.out.println(b);//123.456字符串类型

        String s3=b+"";//任何类型与字符串类型连接，结果都是字符串类型，效率低
        System.out.println(s3);//123.456字符串类型


        int a1=3456;
        String a2=String.valueOf(a1);
        System.out.println(a2);


        double b1=3.1415926;
        String b2=String.valueOf(b1);
        System.out.println(b2);

        String c1=b2+"";
        System.out.println(c1);

        int t1=9876;
        String t2=String.valueOf(t1);
        System.out.println(t2);
        double w1=7.8905;
        String w2=String.valueOf(w1);
        System.out.println(w2);
        String y1=w2+"";
        System.out.println(y1);
    }
}
